package gases.as3.testing
{
	import flash.display.DisplayObject;
	import flash.display.Loader;
	import flash.display.LoaderInfo;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	import flash.net.URLRequest;
	import flash.utils.getTimer;
	
	import gases.as3.debug.DebugBase;
	import gases.as3.librarys.compnents.resource.MacroResourceManagaers;
	import gases.as3.librarys.compnents.skin.SkinStylesMangaer;
	import gases.as3.librarys.compnents.skin.SkinTransform;
	import gases.as3.librarys.compnents.skin.data.BaseSkin;
	import gases.as3.librarys.compnents.skin.transform.TransformXML;
	import gases.as3.librarys.compnents.ui.control.GLabelButton;
	
	public class TestingGLabelButton extends DebugBase
	{
		public function TestingGLabelButton()
		{
			stage.align = StageAlign.TOP_LEFT;
			stage.scaleMode = StageScaleMode.NO_SCALE;
			
			var loader:Loader = new Loader();
			loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
			loader.load(new URLRequest("assets/btnSkin.swf"));
		}
		
		private function onComplete(e:Event):void
		{
			
			var swf:DisplayObject = LoaderInfo(e.target).content as DisplayObject;
			MacroResourceManagaers.instance.UIResManager.setUISkinSwf(swf);
			var transform:SkinTransform = new SkinTransform();
			transform.setConfigTransform(new TransformXML());
			transform.resloveSkinConfig(xml);
			
			
			var skin:BaseSkin = SkinStylesMangaer.instance.getSkinData("green_btn") as BaseSkin;
			var t:int = getTimer();
			//			_btn = new GButton("测试按钮");
			//			_btn.skin = skin;
			//			_btn.color = 0xFF0000;
			//			this.addChild(_btn);
			
			var a:int;
			var b:int;
			for(var i:int = 0; i < 1000; i++)
			{
				_btn = new GLabelButton("按钮");
				_btn.skin = skin;
				_btn.color = 0xFFFFFF;
				_btn.isSelect = true;
				_btn.selectState = true;
				_btn.enable = false;
				_btn.x = a * 53;
				_btn.y = b * 25;
				_btn.width = 60;
				this.addChild(_btn);
				a++;
				if(a == 28)
				{
					b++;
					a=0;
				}
			}
			trace(getTimer() - t);
			
		}
		
		
		private var _btn:GLabelButton;
		private var xml:XML = <root xmlns:skin="gases.compnents.ui.skin">
									<skin:button type="button" scale9_top="5" scale9_left="5" scale9_right="5" scale9_bottom="5" skinname="green_btn" width="60" height="20">
										<styles stylesName="button_down" resName="btn_green_down"/>
										<styles stylesName="button_up" resName="btn_green_out"/>
										<styles stylesName="button_over" resName="btn_green_over"/>
										<styles stylesName="button_out" resName="btn_green_out"/>
									</skin:button>
									<skin:button type="button" scale9_top="5" scale9_left="5" scale9_right="5" scale9_bottom="5" skinname="red_btn" width="60" height="20">
										<styles stylesName="button_down" resName="btn_green_down"/>
										<styles stylesName="button_up" resName="btn_green_out"/>
										<styles stylesName="button_over" resName="btn_green_over"/>
										<styles stylesName="button_out" resName="btn_green_out"/>
									</skin>
								</root>;
	}
}





